package com.flash.ReportManagement.controller;

import com.flash.ReportManagement.Service.RollDifferenceService;
import com.flash.ReportManagement.entity.RollDifference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

@RestController
public class RollDifferenceController {

    @Autowired
    RollDifferenceService rollDifferenceService;

    @RequestMapping("selectRollDifference")
    public Map selectRollDifference(String dealTime){
        System.out.println("进轧差");
        System.out.println("dealTime="+dealTime);
        List<RollDifference> rollDifferenceList = rollDifferenceService.selectRollDifference(dealTime);
        System.out.println("删除前的集合数为:"+rollDifferenceList.size());
        Map map=new HashMap();
        Iterator<RollDifference> iterator = rollDifferenceList.iterator();
        while (iterator.hasNext()){
            RollDifference difference = iterator.next();
            if (difference.getInMoney()==0 && difference.getOutMoney()==0 && difference.getAmountToday()==0 && difference.getNetReceipts()==0){
                System.out.println("difference"+difference);
                System.out.println("进remove");
                iterator.remove();
            }
        }
        System.out.println("rollDifferenceList="+rollDifferenceList);
        System.out.println("删除后的集合数为:"+rollDifferenceList.size());
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", 10);
        map.put("data", rollDifferenceList);
        return map;
    }
}
